<template>
  <div class="Home_home">
    <div class="pubBig Privilege">
      <div class="h0">
        <p class="lt">首页</p>
      </div>
      <div class="body_body">
        <div class="out_logain">
          <button
            class="btn btn-danger"
            style="float: right; height: 60%; margin: 8px"
            @click="outSys()"
          >
            <i class="fa fa-power-off auto"></i>
          </button>
          <span style="float: right; height: 60%; margin: 14px; color: #fff"
            >当前用户：{{ LoginInfor.UserName }}</span
          >
          <span style="float: right; height: 60%; margin: 14px; color: #fff"
            >所属机构：{{ LoginInfor.HospitalName }}</span
          >
        </div>
        <h1 style="color: #fff; text-align: center; margin-bottom: 50px">
          ———— 信息集成平台 ————
        </h1>
        <div class="body_style">
          <span
            v-for="i in but_list"
            style="display: inline-block; justify-content: space-evenly"
          >
            <div class="body_item" @click="to(i.id, i.url, i.label, i)" round>
              {{ i.label }}
            </div>
          </span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      but_list: [
        { label: "首页", id: "1.1", url: "/SystemManagement/Index_Home" },
        {
          label: "主数据管理平台",
          id: "2.1.1",
          url: "/SystemManagement/EMPIAdministration",
        },
        {
          label: "大数据服务中台",
          id: "3.1.1",
          url: "/SystemManagement/DatasetMapping",
        },
        {
          label: "一体化服务平台",
          id: "4.1",
          url: "/SystemManagement/Service_Management",
        },
        {
          label: "文档管理平台",
          id: "8.1",
          url: "/SystemManagement/Patient_master_index",
        },
        {
          label: "一体化监控",
          id: "6.0",
          url: "/SystemManagement/Integrated_Monitoring_Home",
        },
        {
          label: "权限管理平台",
          id: "7.1",
          url: "/SystemManagement/UserInformationTable",
        },
        // { label: '系统管理', id: '5.1.1', url: '/SystemManagement/SystemLocalConfiguration' },
        {
          label: "临床数据中心",
          id: "10.1",
          url: "/SystemManagement/Clinical_data_center",
        },
        {
          label: "患者全息图",
          id: "9.1",
          url: "/SystemManagement/System_Diagra",
        },
      ],
      LoginInfor: {},
    };
  },
  methods: {
    to(id, url, label, i) {
      // console.log(i);
      console.log("主页跳转数据");
      console.log(i);
      this.$router.push({
        path: url,
      });
    },
    getBut_list() {
      let info = JSON.parse(localStorage.getItem("LoginInfor")).Roles[0];
      this.$get("/roles/" + info + "/permissions").then((res) => {
        console.log(res);
        this.but_list = res.data;
      });
    },
    outSys() {
      var data = "";
      this.$post("UserManage/Logout", data)
        .then((res) => {
          // console.log("登录信息返回结果");
          // console.log(res);
          if (res.code == 0) {
            // console.log(res.data);
            localStorage.setItem("LoginInfor", "");
            localStorage.setItem("user_id", "");
            localStorage.setItem("user_name", "");
            localStorage.setItem("dept_id", "");
            localStorage.setItem("Token", "");
            this.$setToken(null);
            this.$router.replace({
              path: "/login",
            });
          } else {
            this.$message({ message: res.msg, type: "error" });
          }
        })
        .catch((err) => {
          console.log(err);
          this.$message({
            message: "登录异常",
            type: "error",
          });
        });
    },
  },
  mounted() {
    // document.getElementById("2").focus();
    var loginInfor = localStorage.getItem("LoginInfor");
    this.LoginInfor = JSON.parse(loginInfor);
  },
  created() {
    if (this.$route.query.Token) {
      localStorage.setItem("Token", this.$route.query.Token);
    }
    // this.getBut_list();
  },
};
</script>
<style lang="scss">
.top-input {
  display: inline-block;
  width: 350px;
}

.box-top {
  margin-top: 15px;
  margin-left: 5px;
}
.Home_home {
  .body_body {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 100px;
    overflow: auto;
    background: url(../../../src/assets/loginBg.jpg) no-repeat center;
    background-size: 100%;
    .out_logain {
      position: absolute;
      top: 0;
      right: 0;
    }
    .body_style {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-evenly;
      transition: all 5s;
      .body_item {
        width: 285px;
        height: 150px;
        margin: 25px;
        padding: 20px 5px;
        font-size: 26px;
        background: url(../../../src/assets/toGo.png) no-repeat center;
        background-size: 150%;
        text-align: center;
        line-height: 135px;
        cursor: pointer;
        color: rgb(48, 134, 191);
        font-weight: 700;
        text-shadow: 5px 5px 5px rgba(168, 212, 241, 0.3);
        transition: all 0.6s;
      }
      .body_item:hover {
        transform: scale(1.4);
        color: #000;
        background: url(../../../src/assets/toGo_hover.png) no-repeat center;
      }
    }
  }
}
</style>
